<%@page pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"
	language="java" import="java.util.*"%>
<%@page import="com.pub.database.*"%>
<%@page import="com.pub.tools.*"%>
<jsp:useBean id="WebFunction" scope="request"
	class="com.pub.web.WebFunction" />
<%

	Vector<Object> lvtrParam = new Vector<Object>();
	QueryBean obj = null;
	String lstrOnloadScript = "init();";
	String prg_status = null;
	String flow_num = null;
	String flow_no = null;
	String flow_code = null;
	String rout_no = null;
	String sign_date = null;
	String r_empno = null;
	String sign_note = null;
	String strDBAlias = null;
	String strSrcCharSet = null;
	String strTarCharSet = null;

	try {
		prg_status = request.getParameter("prg_status");

		flow_num = request.getParameter("flow_num");
		flow_code = flow_num.substring(0, 3);
		flow_no = request.getParameter("flow_no");
		rout_no = "0";
		sign_date = com.pub.tools.PublicFunction
				.getSYSDATE("yyyy/MM/dd HH:mm:ss");
		r_empno = request.getParameter("r_empno");
		sign_note = request.getParameter("sign_note");

		strDBAlias = request.getParameter("db_alias");
		strSrcCharSet = request.getParameter("source_charset");
		strTarCharSet = request.getParameter("target_charset");
		obj = new QueryBean(strDBAlias, false, strSrcCharSet,
				strTarCharSet);

		if (prg_status != null && prg_status.equals("rejectnote")) {
			lvtrParam.add(flow_code);
			lvtrParam.add(flow_num);
			lvtrParam.add(flow_no);
			lvtrParam.add(rout_no);
			lvtrParam.add(PublicFunction.getTimestempDate(sign_date));
			lvtrParam.add(r_empno);
			lvtrParam.add(sign_note);
			String strSql = "insert into wkf_log (flow_code,flow_num,flow_no,rout_no,sign_date,employee_no,sign_note,r_flow_no,r_employee_no,log_st,reject_no)";
			strSql += "values(?,?,?,?,?,?,?,'00','ALL','N','00')";

			boolean blnReturn = obj.executeSQL(strSql, lvtrParam); //執行SQL ,成功傳回true,失敗傳回false

			if (blnReturn) {
				lstrOnloadScript = lstrOnloadScript
						+ "alert('駁回記錄完成,並立即關閉簽核頁');window.returnValue='success';window.close();";
			}
		}
	} catch (Exception e) {
	} finally {
		lvtrParam = null;
		try {
			obj.close();
		} catch (Exception e) {
			System.out
					.println("can not close querybean in /PUBPAGE/reject_note.jsp");
		}
		obj = null;
	}
%>
<HTML>
<HEAD>
<LINK HREF="/PUBPAGE/general/workflow.css" REL="STYLESHEET"
	TYPE="TEXT/CSS">
<title>駁回原因</title>
<base target='_self' />
<SCRIPT type="text/javscript" language="javascript1.2">
function rejectCheck(){
   if(document.form.sign_note.value==""){
     alert("請填寫駁回原因");
     return false;
   }
   else{
     document.all.item("prg_status").value= "rejectnote";
   }
 }

 function init(){
  window.moveTo((screen.width-document.body.clientWidth)/2-5,(screen.height-document.body.clientHeight)/2-60);//開窗置中
 }
</SCRIPT>
</HEAD>
<BODY
	onLoad="javascript:<%=lstrOnloadScript == null ? "" : lstrOnloadScript%>">

<CENTER>
<FORM NAME="form" METHOD=POST action="reject_note.jsp"
	onSubmit="return rejectCheck()"><BR />
<TABLE BORDER="0" WIDTH="520px" CELLSPACING="1" CELLPADDING="0">
	<TR>
		<TD ID="td_sign_note" CLASS="td_head" WIDTH="15%">駁回原因：</TD>
		<TD CLASS="td_content" WIDTH="85%"><TEXTAREA rows="5" cols="75"
			NAME="sign_note" CLASS="textarea"></TEXTAREA></TD>
	</TR>
</TABLE>
<TABLE BORDER="0" WIDTH="520px" CELLSPACING="1" CELLPADDING="0">
	<TR>
		<TD><font color="red">請填寫駁回原因，填寫完畢按「確定」鍵立即駁回。</font></TD>
	</TR>
</TABLE>
<TABLE BORDER="0" WIDTH="520px" CELLSPACING="0" CELLPADDING="0">
	<TR>
		<TD CLASS="td_head" WIDTH="100%" ALIGN="CENTER"><INPUT
			type="submit" name='confirm' value='確定' CLASS="button b_normal" /> <INPUT
			type="reset" name='cancel' value='清除' CLASS="button b_normal" /> <INPUT
			type="button" name='exit' value='離開' CLASS="button b_normal"
			onclick="window.close();" /> <INPUT TYPE="hidden" NAME="prg_status"
			value="<%=prg_status%>" /> <input type="hidden" name="flow_num"
			value="<%=flow_num%>" /> <input type="hidden" name="flow_no"
			value="<%=flow_no%>" /> <input type="hidden" name="rout_no"
			value="<%=rout_no%>" /> <input type="hidden" name="r_empno"
			value="<%=r_empno%>" /> <input type="hidden" name="db_alias"
			value="<%=strDBAlias%>" /> <input type="hidden" name="target_charset"
			value="<%=strTarCharSet%>" /> <input type="hidden"
			name="source_charset" value="<%=strSrcCharSet%>" /></td>
	</TR>
</TABLE>
</FORM>
</CENTER>
</BODY>
</HTML>
